home *** CD-ROM | disk | FTP | other *** search
-
- This routine is a resident keyboard interrupt interceptor which displays
- the status of the Capslock and Numlock keys. If Capslock is on, a "C"
- will be displayed in the upper right hand corner of the display.
- Similarly, a "N" signifies the Numlock mode.
-
- The display is updated after each keystroke. That is, if you
- install KEYSTAT with capslock on, nothing will be displayed until
- AFTER you strike a key (for more details, see below).
-
- To use the program, type
- KEYSTAT ON
- to install the program or
- KEYSTAT OFF
- to cancel it. To display the current state, type
- KEYSTAT
- The command syntax is patterned after the DOS BREAK command.
-
- This program requires DOS 2.0 or later. If loaded on a pre-DOS 2.0 system,
- an error message is displayed.
-
- This routine is called each time a key is pressed. It will remain resident
- until the system is rebooted or cancelled via the OFF command. Note, however,
- that the memory allocated to the program when it is installed is NOT freed
- when the routine is turned OFF. The resident portion of the program takes
- about 650 or so bytes of memory although the operable portion of the program
- (that is, the code that is executed each time a key is pressed) is around
- 150 bytes; the available memory reported by CHKDSK, etc... is decreased when
- KEYSTAT is loaded. Turning KEYSTAT ON, then OFF, then ON again will load another
- copy of the program into memory, decreasing the available memory even further.
- This should not be a problem unless you do this twenty or thirty times.
-
- KEYSTAT simply inserts itself "in series" behind the existing interrupt handler
- and thus SHOULD be compatible with other keyboard utilities such as PROKEY,
- etc... as long as they follow the IBM coding guidelines. Other programs
- may or may not be compatible with KEYSTAT. I do not have any of these other
- programs, so there is no way for me to test KEYSTAT with them. Let me know
- if you have problems using other programs with KEYSTAT.
-
- This program is adapted from an aritcle in October '83 PC-World Magazine,
- page 267. The author of the original version, called KEYFLAGS, is Morton
- Kaplon. I found KEYFLAGS to be extremely userful and, as an excercise,
- decided to write my own version. In the process, I ended
- up adding a few enhancements and changed the name to KEYSTAT.
-
- Here is a summary of the differences between KEYFLAGS and KEYSTAT:
- 1. All absolute references to BIOS in KEYFLAGS are replaced by
- interrupts in KEYSTATS.
- 2. When KEYSTATS is loaded, it checks to see if it was already
- resident. KEYFLAGS resets the vector every time, thus allowing
- nesting the code several levels deep. This was unnecessary since
- the display need only be update once for every keystroke. Additionally,
- it was undesireable since it would often hang the system.
- 3. KEYFLAGS assumed that BIOS was servicing INT 9 and thus
- precluded using PROKEY, etc... with it. KEYSTAT makes no such
- assumptions. The previous keyboard service routine, be it BIOS, PROKEY,
- or whatever, is saved and that routine is re-installed when
- KEYSTAT is turned OFF.
- 4. Because KEYSTAT uses the new DOS INT 35h, it requires DOS 2.0.
- There is no real reason why this could not be changed to get the
- current interrupt vector directly from memory so that any DOS version
- could be used, but it makes the code a little cleaner. KEYFLAG can
- be used with any existing version of DOS but compatibility with
- future release is questionable. KEYSTAT should be compatible with
- future releases of DOS.
- 5. KEYFLAGS uses the "@" symbol to signify caps state and the "#" for
- numlock state. I found these rather cryptic and changed them to
- "C" and "N", respectively in KEYSTAT.
- 6. As mentioned earlier, I added command line parameters in KEYSTAT to
- allow for turning the routine OFF and to make it easy to use.
- 7. A bug in KEYFLAGS has been fixed in KEYSTAT. The bug occurs when
- the program is resetting the vector for INT 9. Should an interrupt
- occur while the vector is being reset, the system will go off into
- computer "never-never land" the next time you press a key. KEYSTAT
- disables interrupts while this critical section of code is executed.
- Admittedly, this is a rare bug in actual occurence, but it is still
- a bug.
-
- You may make and distribute as many copies of this program as you wish.
- Feel free to modify, mutilate, or adulterate this program. If you come
- up with an bug or improvement, please let me know by writing me at this
- address:
- Tony A. Rhea
- 1030 Ivy Lane
- Cary, NC 27511
- If you do modify it, please give both myself and the original author
- (Morton Kaplon) credit in the program. This helps to preserve our egos
- and increase our fame (but, unfortunately, NOT our fortunes). Also, I
- would appreciate a copy of the modified version, preferably on disk (I'll
- be happy to return your diskette).
-
- If you like this program ( or HATE it ), please let me know. Drop me
- a line at the address given above.
-
- This program has been submitted for publication in PC-WORLD magazine.
-
- I have experimented with an extension of this routine which also displays
- the INSERT and SCROLL-LOCK states as well but found that it caused too much
- overhead -- one could easily "outtype" the system. Using DOS function 2
- to automatically advance the cursor could eliminate the necessity of moving
- the cursor thru INT 10h since the cursor is automatically advanced when
- the character is displayed. However, the current display attribute is
- used so the status characters don't stand out very well. Using DOS function
- 9 and printing all the status characters at once from a (constructed) string
- would also work and would allow specifying an "attribute" to use (see the
- discussion of "Extended Screen and Keyboard Control" in chapter 13 of the
- DOS 2.0 manual). However, that attribute will still be in effect after
- the status characters are displayed.
-
- The initialization code is overlaid by the next program DOS loads so that
- only the ego statement, some variables, and the operable code remain resident.
-
- The video positions are fixed (but can be changed in the equates below)
- and thus will wipe out anything another program puts there. It is best
- not to put these at the bottom of the screen because the characters would
- be scrolled up. Putting them at the top of the screen solves this problem.
-
- KEYSTAT waits until BIOS (or whoever) has serviced the keyboard interrupt
- before it updates the display. This is because it uses the KB_FLAG that
- BIOS (or it's predecessor) must update. If the user presses the Capslock key,
- KEYSTAT lets the flag be updated first and then gets the flag to sense the
- keyboard status. If KEYSTAT had updated the display before letting the
- original interrupt servicer update the flag, the display would not be correct
- until the NEXT key is pressed.
-
- Note that INT 25h CANNOT be used for setting a vector permanently. When your
- program terminates, DOS resets any vectors your program changes. The only
- way to make the change permanent is by a direct move into the vector table.
-
- I have made heavy use of macros in KEYSTAT -- I find that it enhances the
- readability greatly. The code is not anything fancy nor is it particuarly
- good, but it works. This was my first big assembler program (by big I mean
- anything over 10 lines long). KEYSTAT is a pieced together from code fragments
- from KEYFLAGS and other book and magazine articles. Therefore, if you find
- that I pushed CS/restored DS when I didn't really need to, it is certainly
- because of my lack of understanding the deeper truths of assembler. Please
- feel free to improve upon KEYSTAT in any way you see fit.
-
- Pseudocode:
-
- if not(DOS 2.0) then
- error message
- exit
- else
- { we have 2.0 - decode parm }
- get command line parameter
- convert to uppercase
- if (null parameter) then
- { display current status }
- if (already installed) then
- on message
- else
- off message
- endif already installed
- else
- { we got a parameter - see if it matches ON }
- if (ON) then
- if (already resident) then
- on message
- exit
- else
- make resident
- on message
- terminate, leaving operable code resident
- endif already resident
- else
- { command wasn't ON -- is it OFF? }
- if (OFF) then
- if not(already installed) then
- off message
- exit
- else
- reset keyboard vector to original servicer
- off message
- exit
- endif not already installed
- else
- { we got a command that wasn't OFF or ON }
- error message
- exit
- endif off
- endif on
- endif null parameter
- endif not dos 2.0
-
-
- Revision history:
- rev 1.0 10/15/83 { original release }
- rev 1.1 10/29/83 { speed improvement }
-
-
- Copyright (C) 1983 Tony Alan Rhea
- This program may be copied and distributed for personal use
- but not for profit provided this notice is included. Author makes
- no warranty, expressed or implied, as to the correct nature and
- operation of this software.
- d. Author makes
- no warranty, ex